#ifndef COMMAND_DEFINE_H
#define COMMAND_DEFINE_H

#include <QObject>
#define BigAndSmall

namespace Command {
enum RecvCmd{
    RecvExternExposure       = 0x01,
    RecvPhotoMetry           = 0x02,
    RecvRestart              = 0x03,
    RecvHeartBeat            = 0x18
};

enum SendCmd{
    CmdExternExposure       = 0xF1,
    CmdPhotoMetry           = 0xF2,
    CmdRestart              = 0xF3,
    CmdHeartBeat            = 0xE8
};

enum CameraStatusCode{
    CsCommandOk          = 0x00,
    CsCheckCrcError       = 0x01,
    CsNoReply            = 0x02,    //无回复
    CsError              = 0x03,
};

enum PhotoNumber{
        None,       //不拍照
        OnePhoto,   //触发单帧
        MorePhoto   //连续触发
    };

#pragma pack(1)//设定为1字节对齐
struct CommandHeader
{
   unsigned char preamble[2];		//以0xEB90h 标志一个新的数据包的开始
   quint16 frameNum;				//帧计数从0000-ffff
   unsigned char cameraId;          //设备码
   unsigned char codeNum;           //指令码
   unsigned int commandLength;      //指令长度
};


struct CommandEnd
{
    unsigned char preamble[2];		//以0x0D0Ah 标志一个新的数据包的结尾
};
struct CommandData
{
    CommandHeader header;			//消息头
    QByteArray params;				//具体参数
    unsigned char ExclusiveOrCheck;  //异或校验
    unsigned char SumCheck;         //加和校验
    CommandEnd end;
};
#pragma pack(pop)//恢复对齐状态
typedef QList<struct CommandData> CommandDataList;

static unsigned char sPreambleSignature[2] = { 0xEB, 0x90};
static unsigned char sEndSignature[2] = { 0x0D, 0x0A};

}
#endif // COMMAND_DEFINE_H
